# # 文件打开用open( )
# f = open('1.txt', 'r', encoding="utf-8")
# # 读取文件用read( )
# print(f.read())
#
# # 使用with open( )as if
# with open('2.text', 'r', encoding="utf-8") as file:
#     test = file.read()
# print(test)
#
# # 使用绝对路径
# ff = open(r"C:\Users\Administrator\Desktop\3.txt", encoding="utf-8")
# print(ff.read())
#
#
#
# # 写文件write( )
# fff = open('3.txt', 'w', encoding='utf-8')
# fff.write('hello python')
# fff.close()
#
#
# date = '你好!'
# with open('3.txt', 'a', encoding='utf-8') as f:
#     f.write(date)

#
# # 处理excel文件时使用pandas
# import pandas as pd
# # 下载 requests scrapy pandas
# # 读取excel文件 获取Deteframe
# df = pd.read_excel(r"C:\Users\Administrator\Desktop\111.xlsx")
# print(df)
#
#
#
# # 写文件到excle
# a1 = {'name': 'xiaohong', 'age': 20}
# a2 = {'name': 'zhangsan', 'age': 21}
# a3 = {'name': 'lishi', 'age': 22}
# l1 = [a1, a2, a3]
# df1 = pd.Datarame(l)
# print(df1)
#
# df1.to_excel('222.xls', index=False)


# 处理word文档，需要下载python-docx
# 导入docx库的Document
from docx import  Document
# 打开
doc = Document('2023年国务院政府工作报告.docx')
print(doc)
# 获取word段落，
p = doc.paragraphs
print(p)
print(len(p))
# 遍历列表，显示段落内容，使用text
for i in p:
    print(i.text)